#include <iostream>
#include <vector>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
using namespace std;
struct Node {
	int col, row;
	int value;
};
struct Nodes {
	int cols, rows, nums = 0;
	vector<Node> Matrix;
};

void printNums(vector<vector<int>> &n)
{
	int row = n.size();
	int col = n[0].size();
	for (int i = 0; i < row; i++)
	{
		for (int j = 0; j < col; j++)
		{
			cout << n[i][j] << "  ";
		}
		cout << endl;
	}
	cout << endl;
}
int main(int argc, char** argv) {
	vector<vector<int>> originNums = {{0, 0, 0, 1}, {1, 0, 0, 1}, {3, 0, 1, 0}};
	cout << "转置前:" << endl;
	printNums(originNums);
	Nodes nodes;
	nodes.rows = originNums.size();
	nodes.cols = originNums[0].size();
	for (int i = 0; i < 3; i++)
	{
		for (int j = 0; j < 4; j++)
		{
			if (originNums[i][j] != 0)
			{
				Node node;
				node.col = j;
				node.row = i;
				node.value = originNums[i][j];
				nodes.nums++;
				nodes.Matrix.push_back(node);
			}
		}
	}

	vector<vector<int>> afterNums(4, vector<int> (3, 0));
	for (auto &a : nodes.Matrix)
	{
		int temp = a.col;
		a.col = a.row;
		a.row = temp;
		afterNums[a.row][a.col] = a.value;
	}
	cout << "转置后:" << endl;
	printNums(afterNums);
	return 0;
}
